package com.huluobo.base.mvvm;

import android.graphics.Color;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
import androidx.lifecycle.ViewModelProvider;

/**
 * Created by LC on 2024/8/15.
 */
public abstract class BaseMVVMActivity<VDB extends ViewDataBinding, VM extends BaseViewModel> extends AppCompatActivity {
    //视图绑定
    protected VDB binding;
    //对应的VIewModel
    protected VM viewModel;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, getLayoutId());
        viewModel = new ViewModelProvider(this).get(getViewModel());
        initView();
        initData();
        getWindow().setStatusBarColor(Color.BLACK);
    }

    protected abstract void initData();

    protected abstract void initView();

    //返回对应的ViewModel的class
    protected abstract Class<VM> getViewModel();

    protected abstract int getLayoutId();


}
